<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	template="/xhtml/bases/base.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:bargas="http://barganhas.com.br/barganhas">
	
	<ui:define name="bodyNavigation">
		<h:panelGroup id="indexNavigationBox" layout="block">
			<h:panelGroup  id="categories" layout="blocl">
				<p class="title">#{msg.categories}</p>
				
				<ul>
					<ui:repeat var="category" value="#{siteBean.listCategories}">
						<li>
							<h:commandLink value="#{category.name}" action="#{siteBean.search}" >
								<f:setPropertyActionListener target="#{siteBean.categoryFilter}" value="#{category}"/>
							</h:commandLink>
						</li>
					</ui:repeat>
					<li class="categoryShowAll">
						<h:commandLink value="#{msg.msgShowAll}" action="#{siteBean.search}" immediate="true"/>
					</li>
				</ul>
			</h:panelGroup>
			
			<h:panelGroup id="productsList" layout="block">
				<h:panelGroup layout="block" id="bannerSite" style="text-align: center;">
					<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="550" height="403" id="banner" align="">
						<param name="movie" value="#{request.contextPath}/images/banner/projeto5_1_3.swf" />
						<param name="quality" value="high" />
						<param name="wmode" value="transparent" />
						<embed src="#{request.contextPath}/images/banner/projeto5_1_3.swf" quality="high" bgcolor="#FFFFFF" width="550" height="403" name="banner" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
					</object>
				</h:panelGroup>
				
				<h:panelGroup id="lastUpdates" layout="block">
					<p class="title">#{msg.lastAnnouncement}</p>
					
					<bargas:carrosel id="carroselLastAdvertisement" listAdvertisement="#{siteBean.lastAdvertisements}"/>
				</h:panelGroup>

				<h:panelGroup id="mostViewed" layout="block">
					<p class="title">#{msg.mostViewed}</p>
					
					<bargas:carrosel id="carroselMostViewed" listAdvertisement="#{siteBean.mostViewed}"/>
				</h:panelGroup>
				
				<h:panelGroup id="betterReputations" layout="block">
					<p class="title">#{msg.betterReputations}</p>
					
					<h:panelGroup class="carrosel" layout="block">
						
						<h:panelGroup class="indexListItens" layout="block" style="height: 340px; background-color: #F7F7F7;margin-left:0; padding-left: 20px;">
							<ul style="width: auto;">
								<ui:repeat var="user" value="#{siteBean.highlightedUsers}">
									<li>
										<h:commandLink action="#{siteBean.loadUserAccountConsult}">
											<h:graphicImage value="/images/anonymous_profile.png"
												rendered="#{user.profileImage eq null}"/>
											<h:graphicImage value="/fileserver?q=#{user.profileImage.id}"
												rendered="#{user.profileImage ne null}"/>
												
											<f:setPropertyActionListener target="#{siteBean.userAccount}" value="#{user}"/>
										</h:commandLink>

										<p class="descProduct"><a href="#">#{user.nickname}</a></p>
									</li>
								</ui:repeat>
							</ul>
							
						</h:panelGroup>
					</h:panelGroup>
				</h:panelGroup>
			</h:panelGroup>
			
			<h:panelGroup id="leftSide" layout="block">
			
				<c:choose>
					<!-- register yourself -->
					<c:when test="#{appSessionBean.userAccount eq null}">
						<p class="title">#{msg.registerYourSelf}</p>
						
						<h:panelGroup layout="block" id="registerBox" styleClass="boxLeftSide">
							<fieldset>
								<ol>
									<li>
										<h:outputLabel value="#{msg.registerName}:" for="userName" />
										<h:inputText id="userName" size="25" value="#{userAccountBean.userAccount.fullname}"/>
									</li>
									<li>
										<h:outputLabel value="#{msg.registerEmail}:" for="userEMail" />
										<h:inputText id="userEMail" size="25" value="#{userAccountBean.userAccount.email}"/>
									</li>
								</ol>
							</fieldset>
							
							<h:panelGroup id="userRegisterLogin" layout="block">
								<a4j:commandButton actionListener="#{userAccountBean.prepareRegister}"
											styleClass="customButton"
											id="registerUser"
											value="#{msg.registerYourSelf}"
											immediate="false"
											execute="registerBox"
											render="accountNewPopupForm"
											style="margin-right: 10px;"
											onclick="popupLoading(true);"
											oncomplete="popupLoading(false);"/>
											
								<h:commandLink value="#{msg.alreadyRegistered}" action="#{userAccountBean.goToLogin}"/>
							</h:panelGroup>
						</h:panelGroup>
					</c:when>
					<c:otherwise>
						<h:panelGroup id="mylastAdvertisements" layout="block" styleClass="boxLeftSide">
							<h:panelGroup layout="block" style="border-bottom: 2px solid #D5D5D5; padding: 0px 5px 5px 5px;">
								<h:outputText value="#{msg.userAccountMyLastAdvertisements}"/>
							</h:panelGroup>
							
							<c:choose>
								<c:when test="#{bargas:isCollectionOk(siteBean.myLastAdvertisements)}">
									<t:dataTable value="#{siteBean.myLastAdvertisements}" var="advertisement" style="width: 100%;">
										<h:column>
											<h:commandLink  action="#{advertisementBean.consult}">
												<h:panelGrid styleClass="myLastAdvertisementOne" style="width: 100%;">
													<!-- advertisement's description -->
													<h:outputText value="#{advertisement.title}"/>
	
													<!-- advertisement's value -->
													<h:panelGroup layout="block">
														<h:outputText value="#{msg.msgRealCurrency} "/>
														<h:outputText value="#{advertisement.value}">
															<f:converter converterId="ConverterDoubleCurrencyReal"/>
														</h:outputText>
													</h:panelGroup>
												</h:panelGrid>
												
												<f:setPropertyActionListener value="#{advertisement}" target="#{advertisementBean.advertisement}"/>
											</h:commandLink>
										</h:column>
									</t:dataTable>
								</c:when>
								<c:otherwise>
									<h:panelGroup id="boxNoneAdvertisementMy" layout="block">
										<h:outputText value=" #{msg.msgNoneAdvertisementToMe} "/>
										<h:commandLink value="#{msg.msgClickHere}" action="#{advertisementBean.prepareNewStepOne}"/>
										<h:outputText value=" #{msg.msgToCreateNewAdvertisement} "/>
									</h:panelGroup>
								</c:otherwise>
							</c:choose>
						</h:panelGroup>
					</c:otherwise>
				</c:choose>
				
				<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="290" height="100" id="anuncie" align="">
					<param name="movie" value="#{request.contextPath}/images/banner/Anuncie_v1.swf" />
					<param name="quality" value="high" />
					<param name="wmode" value="transparent" />
					<embed wmode="transparent" src="#{request.contextPath}/images/banner/Anuncie_v1.swf" quality="high" bgcolor="#FFFFFF" width="290" height="100" name="anuncie" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
				</object>

				<h:panelGroup layout="block" styleClass="advertisementBannerRight">
					<a href="http://www.nacprint.com.br" target="_blank">
						<h:graphicImage value="/images/banner/nacprint-v3.png" />
					</a>
				</h:panelGroup>
			</h:panelGroup>
		</h:panelGroup>
	</ui:define>
</ui:composition>
